# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ciphr
pkgver=127.5da7137
_gemver=0.0.6
pkgrel=14
pkgdesc='A CLI tool for encoding, decoding, encryption, decryption, and hashing streams of data.'
groups=('blackarch' 'blackarch-crypto')
url='https://github.com/frohoff/ciphr'
arch=('any')
license=('MIT')
depends=('ruby' 'ruby-bundler')
makedepends=('git')
source=("git+https://github.com/frohoff/$pkgname.git")
install="$pkgname.install"
sha256sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count master).$(git rev-parse --short master)
}

prepare() {
  cd $pkgname

  sed -i 's|"bundler", "~> 1.3"|"bundler"|g' "$pkgname.gemspec"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname/"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md TODO
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE.txt

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec ./bin/$pkgname "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"
}

